package jdsl.notifier.model;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class Parameters {

	private static Parameters instance;
	private Properties properties;
	private File file = new File("parameters");

	public Parameters() {
		properties = new Properties();
		try {
			properties.load(new FileInputStream(file));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static Parameters getInstance() {
		if (instance == null) {
			instance = new Parameters();
		}
		return instance;
	}

	public String getPassword() {
		return properties.getProperty("password");
	}

	public String getLogin() {
		return properties.getProperty("login");
	}

	public void setLogin(String newLogin) {
		properties.setProperty("login", newLogin);
	}

	public void setPassword(String newPassword) {
		properties.setProperty("password", newPassword);
	}

	public void save() throws IOException {
		properties.store(new FileOutputStream(file), "Program settings");
	}

}
